﻿#define _CRT_SECURE_NO_WARNINGS 1

// BC133 回型矩阵

/*

描述
给你一个整数n，按要求输出n∗n的回型矩阵

输入描述：
输入一行，包含一个整数n 
1 <= n <= 19
输出描述：
输出n行，每行包含n个正整数.

示例1
输入：
4
输出：
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7


*/


#include <stdio.h>

int main()
{
	int n = 0;
	scanf("%d", &n);

	int arr[20][20] = { 0 };

	int count = 1;
	int i = 0;
	int j = 0;
	int z = 0;
	while (count <= n * n)
	{
		i = z;
		for (j = z; j < n - z; j++)
		{
			arr[i][j] = count;
			count++;
		}


		j--;
		for (i = i + 1; i < n - z ; i++)
		{
			arr[i][j] = count;
			count++;
		}

		i--;
		for (j = j - 1; j >= z; j--)
		{
			arr[i][j] = count;
			count++;
		}

		j++; 
		z++;
		for (i = i - 1; i >= z; i--)
		{
			arr[i][j] = count;
			count++;
		}

	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			printf("%d ", arr[i][j]);
		}
		printf("\n");
	}
	return 0;

}